//
//  PSObjectPool.h
//  PrefCore
//
//  Created by Sergey on 5/8/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "PSLinkedList.h"

typedef id<PSListEntry> (^PSObjectPoolCreateObject)();

@interface PSObjectPool : NSObject

/// Initializes the new pool with a block for creating new objects.
-(instancetype)initWithCreateObject:(PSObjectPoolCreateObject)createObject;

/// Preallocate objects inside the pool.
-(void)setCapacity:(NSUInteger)n;

/// Get object from the pool.
-(id<PSListEntry>)get;

/// Put object back to the pool
-(void)putObject:(id<PSListEntry>)entry;

-(void)putList:(PSLinkedList*)list;

@property (nonatomic, readonly) NSUInteger total;

@property (nonatomic, readonly) NSUInteger objectsIn;

@property (nonatomic, readonly) NSUInteger objectsOut;

-(NSString*)description;

@end
